home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 22 April 1997
- // Author: sjt
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // int action
- // 0 - just execute the extend surface operation
- // 1 - show the option box dialog
- // 2 - drag to shelf
- //
- // Return Value:
- // None.
- //
- // Notes:
- // In the future this can be modified to include extend to object
- //
- global proc extendSurfaceEnableBoth( string $joinWidget,
- string $directionWidget,
- string $endWidget,
- string $originalsWidget,
- int $priorityEnd )
- {
- int $enable;
- if( $priorityEnd ) {
- int $end = `radioButtonGrp -q -select $endWidget`;
- int $dir = `radioButtonGrp -q -select $directionWidget`;
-
- $enable = ((3 != $end) && (3 != $dir));
- checkBoxGrp -edit -enable $enable $joinWidget;
-
- $enable = `checkBoxGrp -q -value1 $joinWidget`;
- checkBoxGrp -edit -enable $enable $originalsWidget;
- }
- else {
- int $join = `checkBoxGrp -q -value1 $joinWidget`;
- $enable = $join;
-
- radioButtonGrp -edit -enable3 $enable $endWidget;
- radioButtonGrp -edit -enable3 $enable $directionWidget;
- checkBoxGrp -edit -enable $enable $originalsWidget;
- }
- }
-
- proc setOptionVars(int $forceFactorySettings)
- {
- // Extension Type ( 0 = linear or 1 = circular or 2 = extrapolate ).
- // Used only if extend method is 0
- // Default = 0 = linear. Circular currently disabled.
- //
- if ($forceFactorySettings || !`optionVar -exists extendSurfaceType`) {
- optionVar -intValue extendSurfaceType 0;
- }
-
- // Extend Distance.
- // Used only if extend method is 0
- // Default = 1.00
- //
- if ($forceFactorySettings || !`optionVar -exists extendSurfaceDistance`) {
- optionVar -floatValue extendSurfaceDistance 1.0;
- }
-
- // Extend Direction ( 0 = U, 1 = V, 2 = both)
- // Default = 0
- //
- if ($forceFactorySettings || !`optionVar -exists extendSurfaceDirection`) {
- optionVar -floatValue extendSurfaceDirection 0;
- }
-
- // Extend Start ( 1 = start or 0 = end, 2 = both )
- // Default = 0
- //
- if ($forceFactorySettings || !`optionVar -exists extendSurfaceSide`) {
- optionVar -intValue extendSurfaceSide 0;
- }
-
- // Extend Join ( on = join or off = do not join )
- // Default = ON
- //
- if ($forceFactorySettings || !`optionVar -exists extendSurfaceJoin`) {
- optionVar -intValue extendSurfaceJoin 1;
- }
-
- // keep original (for in place operations is on-1 or off-0 )
- // Used only when joining
- /// Default = 0
- //
- if ($forceFactorySettings || !`optionVar -exists extendSurfaceKeepOriginal`) {
- optionVar -intValue extendSurfaceKeepOriginal 0;
- }
-
- }
-
- //
- // Procedure Name:
- // extendSurfaceSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the extend surface
- // option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc extendSurfaceSetup( string $parent,
- int $forceFactorySettings,
- string $goToTool )
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
- extendSurfaceToolSetup( $forceFactorySettings, $goToTool );
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // extend distance
- floatSliderGrp -edit
- -value `optionVar -query extendSurfaceDistance`
- extendSurfaceDistanceSlider;
-
- // extend type
- int $extendType = `optionVar -query extendSurfaceType`;
- int $extendTypeBtn = ($extendType + 2)/2;
- radioButtonGrp -edit
- -select $extendTypeBtn
- extendSurfaceTypeBtn;
-
- // extend start and join
- //
- int $join = `optionVar -query extendSurfaceJoin`;
- int $start = `optionVar -query extendSurfaceSide`;
- int $dir = `optionVar -query extendSurfaceDirection`;
-
- // convert from value to button number
- // ( 1 = start or 0 = end, 2 = both )
- switch( $start ) {
- case 0:
- $start = 2;
- break;
- case 1:
- $start = 1;
- break;
- case 2:
- default:
- $start = 3;
- break;
- }
-
- radioButtonGrp -edit
- -select $start
- extendSurfaceSideBtn;
-
- radioButtonGrp -edit
- -select ($dir+1)
- extendSurfaceDirectionBtn;
-
- // Extend join
- //
- checkBoxGrp -edit
- -value1 $join
- extendSurfaceJoinBox;
-
- // Keep original.
- //
- checkBoxGrp -edit
- -value1 `optionVar -query extendSurfaceKeepOriginal`
- -enable ($join && (3 != $start))
- extendSurfaceKeepOriginalBox;
-
- extendSurfaceEnableBoth( "extendSurfaceJoinBox",
- "extendSurfaceDirectionBtn",
- "extendSurfaceSideBtn",
- "extendSurfaceKeepOriginalBox",
- 0 );
-
- if( "" != $goToTool ) {
- checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
- scriptToolExtraWidget;
- checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
- scriptToolExtraWidget;
- }
- }
-
- //
- // Procedure Name:
- // extendSurfaceCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc extendSurfaceCallback(string $parent, int $doIt, string $goToTool)
- {
- if( "" != $goToTool ) {
- optionVar -iv extendSurfaceEuc `scriptCtx -q -euc $goToTool`;
- optionVar -iv extendSurfaceLac `scriptCtx -q -lac $goToTool`;
- }
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- int $extendType, $extendTypeBtn;
- $extendTypeBtn = `radioButtonGrp -query -select extendSurfaceTypeBtn`;
- $extendType = 2 * $extendTypeBtn - 2;
- optionVar -intValue extendSurfaceType $extendType;
-
- // extend distance
- //
- optionVar -floatValue extendSurfaceDistance
- `floatSliderGrp -query -value extendSurfaceDistanceSlider`;
-
- // Start or end or both
- // ( 1 = start or 0 = end, 2 = both )
- int $start = `radioButtonGrp -query -select extendSurfaceSideBtn`;
-
- // convert from button number to value
- switch( $start ) {
- case 1:
- $start = 1;
- break;
- case 2:
- $start = 0;
- break;
- case 3:
- default:
- $start = 2;
- break;
- }
- optionVar -intValue extendSurfaceSide $start;
-
- int $dir = `radioButtonGrp -query -select extendSurfaceDirectionBtn` - 1;
- optionVar -intValue extendSurfaceDirection $dir;
-
- // Join
- //
- optionVar -intValue extendSurfaceJoin
- `checkBoxGrp -query -value1 extendSurfaceJoinBox`;
-
- // Keep original.
- //
- optionVar -intValue extendSurfaceKeepOriginal
- `checkBoxGrp -query -value1 extendSurfaceKeepOriginalBox`;
-
- if (1 == $doIt) {
- performExtendSurface( 0, $goToTool );
- string $tmpCmd = "performExtendSurface( 0, \"" + $goToTool + "\")";
- addToRecentCommandQueue $tmpCmd "Extend Surfaces";
- }
- else if( $doIt ) {
- setToolTo $goToTool;
- }
- }
-
- //
- // Procedure Name:
- // createExtendSurfaceUI
- //
- // Description:
- // Fill the contents of the option box for extendSurface command.
- //
- // Input Arguments:
- // The name of the parent layout.
- //
- // Return Value:
- // None.
- //
- proc createExtendSurfaceUI(string $parent, int $inTheTool, string $goToTool)
- {
- setParent $parent;
-
- // Currently, no circular extension:
- radioButtonGrp -label "Extension Type"
- -numberOfRadioButtons 2
- -label1 "Tangent" -da1 0
- -label2 "Extrapolate" -da2 2
- extendSurfaceTypeBtn;
-
- floatSliderGrp -label "Distance"
- -field true
- -min 0.0
- -max 10.0
- extendSurfaceDistanceSlider;
-
- separator;
-
- string $endWidget = `radioButtonGrp -label "Extend Side"
- -numberOfRadioButtons 3
- -label1 "Start" -da1 1 -enable1 1
- -label2 "End" -da2 0 -enable2 1
- -label3 "Both" -da3 0 -enable3 1
- extendSurfaceSideBtn`;
-
- string $directionWidget = `radioButtonGrp -label "Extend Direction"
- -numberOfRadioButtons 3
- -label1 "U" -da1 1 -enable1 1
- -label2 "V" -da2 2 -enable2 1
- -label3 "Both" -da3 3 -enable3 1
- extendSurfaceDirectionBtn`;
-
- separator;
-
- string $joinWidget = `checkBoxGrp -label ""
- -numberOfCheckBoxes 1
- -label1 "Join to Original"
- extendSurfaceJoinBox`;
-
- string $originalsWidget = `checkBoxGrp -label ""
- -numberOfCheckBoxes 1
- -label1 "Keep Original"
- extendSurfaceKeepOriginalBox`;
-
- radioButtonGrp -edit
- -onCommand1 (
- "extendSurfaceEnableBoth"
- + " " + $joinWidget
- + " " + $directionWidget
- + " " + $endWidget
- + " " + $originalsWidget + " 1;"
- )
- -onCommand2 (
- "extendSurfaceEnableBoth"
- + " " + $joinWidget
- + " " + $directionWidget
- + " " + $endWidget
- + " " + $originalsWidget + " 1;"
- )
- -onCommand3 (
- "extendSurfaceEnableBoth"
- + " " + $joinWidget
- + " " + $directionWidget
- + " " + $endWidget
- + " " + $originalsWidget + " 1;"
- )
- $endWidget;
-
- radioButtonGrp -edit
- -onCommand1 (
- "extendSurfaceEnableBoth"
- + " " + $joinWidget
- + " " + $directionWidget
- + " " + $endWidget
- + " " + $originalsWidget + " 1;"
- )
- -onCommand2 (
- "extendSurfaceEnableBoth"
- + " " + $joinWidget
- + " " + $directionWidget
- + " " + $endWidget
- + " " + $originalsWidget + " 1;"
- )
- -onCommand3 (
- "extendSurfaceEnableBoth"
- + " " + $joinWidget
- + " " + $directionWidget
- + " " + $endWidget
- + " " + $originalsWidget + " 1;"
- )
- $directionWidget;
-
- checkBoxGrp -edit
- -onCommand (
- "extendSurfaceEnableBoth"
- + " " + $joinWidget
- + " " + $directionWidget
- + " " + $endWidget
- + " " + $originalsWidget + " 0;"
- )
- -offCommand (
- "extendSurfaceEnableBoth"
- + " " + $joinWidget
- + " " + $directionWidget
- + " " + $endWidget
- + " " + $originalsWidget + " 0;"
- )
- $joinWidget;
-
- if( $inTheTool ) {
- separator;
- checkBoxGrp -ncb 2 -l "Tool Behavior"
- -l1 "Exit on Completion"
- -v1 off
- -on1 ("scriptCtx -e -euc true " + $goToTool)
- -of1 ("scriptCtx -e -euc false " + $goToTool)
-
- -l2 "Auto Completion"
- -v2 on
- -on2 ("scriptCtx -e -lac true " + $goToTool)
- -of2 ("scriptCtx -e -lac false " + $goToTool)
- scriptToolExtraWidget;
- }
- }
-
-
- //
- // Procedure Name:
- // extendSurfaceOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc extendSurfaceOptions( int $inTheTool, string $goToTool )
- {
- // Name of the command for this option box.
- //
- string $commandName = "extendSurface";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- global string $gOptionBoxActionToolItem;
- $gOptionBoxActionToolItem = "modelWithToolExtendSurface";
- global string $gOptionBoxActionToolItemCB;
- $gOptionBoxActionToolItemCB = "extendSurfaceToolScript 3";
-
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // Pass the command name to the option box.
- //
- // Any default option box behavior based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- // RECOMMENDATION: Place the UI in a scroll layout. If the
- // option box window is ever resized such that it's entire
- // contents is not visible then the scroll bars provided by the
- // scroll layout will allow the user to access the hidden UI.
- //
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // Create the UI for the tab that is initially visible.
- //
- createExtendSurfaceUI($parent, $inTheTool, $goToTool);
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Deactivate the default UI template.
- //
- setUITemplate -popTemplate;
-
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'ExtendSurface' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- if( $inTheTool ) {
- button -edit -l "Extend Tool"
- -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
- $applyBtn;
- }
- else {
- button -edit -l "Extend"
- -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
- $applyBtn;
- }
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " 0 \"" +
- $goToTool + "\"; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
- $resetBtn;
-
- // Set the option box title.
- //
- if( $inTheTool ) {
- setOptionBoxTitle("Extend Surface Tool Options");
- }
- else {
- setOptionBoxTitle("Extend Surface Options");
- }
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "ExtendSurfaces" );
-
- // Set the current values of the option box.
- //
- eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
-
- // Show the option box.
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // extendSurfaceHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string extendSurfaceHelp()
- {
- return
- " Command: extendSurface - extends a surface\n" +
- "Selection: a surface ";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // The extendSurface command string.
- //
- proc string assembleCmd()
- {
- setOptionVars(false);
-
- // get the global history flag value
- int $doHistory = `constructionHistory -q -tgl`;
-
- int $extendType = `optionVar -query extendSurfaceType`;
- float $distance = `optionVar -query extendSurfaceDistance`;
- int $side = `optionVar -query extendSurfaceSide`;
- int $dir = `optionVar -query extendSurfaceDirection`;
- int $join = `optionVar -query extendSurfaceJoin`;
- int $replaceOriginal = !`optionVar -q extendSurfaceKeepOriginal`;
-
-
- string $cmd = "doExtendSurfaceArgList 1 { ";
-
- $cmd = $cmd + "\"" + $doHistory + "\", ";
- $cmd = $cmd + "\"" + "0" + "\", ";
- $cmd = $cmd + "\"" + $extendType + "\", ";
- $cmd = $cmd + "\"" + $distance + "\", ";
- $cmd = $cmd + "\"" + $side + "\", ";
- $cmd = $cmd + "\"" + $join + "\", ";
- $cmd = $cmd + "\"" + $replaceOriginal + "\", ";
- $cmd = $cmd + "\"" + $dir + "\" }";
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performExtendSurface
- //
- // Description:
- // Perform the optionBoxExample1 command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the optionBoxExample1 command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
- global proc string performExtendSurface(int $action, string $goToTool)
- {
- int $inTheTool = false;
- if( 3 == $action ) {
- $action = 1;
- $inTheTool = true;
- }
-
- string $cmd = "";
- switch ($action) {
- case 0:
- setOptionVars(false);
- $cmd = `assembleCmd`;
- eval($cmd);
- break;
-
- case 1:
- extendSurfaceOptions( $inTheTool, $goToTool );
- break;
-
- case 2:
- default:
- setOptionVars (false);
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-
-